package demo2;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 何华树
 * Date: 2024-09-10
 * Time: 15:08
 */
public class Main {
    public static void Mysort(Person[] arr) {
        for (int i = 0;i< arr.length-1;i++) {
            for (int j = 0; j < arr.length-1-i; j++) {
                 if(arr[j].name.compareTo(arr[j+1].name) < 0) {
                     Person tmp = arr[j];
                     arr[j] =arr[j+1];
                     arr[j+1] =tmp;
                 }
            }
        }
    }
    public static void main2(String[] args) {
        Person[] people = new Person[3];
        people[0] = new Person("zhangsan",10);
        people[1] = new Person("lisi",22);
        people[2] = new Person("wangwu",19);
        System.out.println("排序之前："+Arrays.toString(people));
        Mysort(people);
//        Arrays.sort(people);
        System.out.println("排序之后：" + Arrays.toString(people));
    }
    public static void main1(String[] args) throws CloneNotSupportedException{
        Person person1 = new Person("小华",10);
        Person person2 = (Person) person1.clone();
        System.out.println(person1.m.money);
        System.out.println(person2.m.money);
        person2.m.money = 99.99;
        System.out.println(person1.m.money);
        System.out.println(person2.m.money);
    }
}
